﻿<%@ Page EnableEventValidation="false" Language="C#" AutoEventWireup="true" CodeBehind="EditMenu.aspx.cs" Inherits="DLV.BackEnd.Pages.EditMenu" %>
<%@ Register Src="~/Controls/TinyMCE.ascx" TagPrefix="uc1" TagName="TinyMCE" %>

<asp:content id="Content1" contentplaceholderid="placeHolderContent" runat="server">
    <div id="toolbar-box">
		<div class="t">
			<div class="t">
				<div class="t"></div>
			</div>
		</div>
		<div class="m">
		    <div id="toolbar" class="toolbar">
			    <table class="toolbar">
			        <tbody>
					    <tr>
						    <td id="toolbar-save" class="button">
						        <asp:LinkButton ID="lbtSave" runat="server" Text="" onclick="lbtSave_Click" CssClass="toolbar">
					                <span id="Span1" title="Save" class="icon-32-save" runat="server"></span>Lưu
					            </asp:LinkButton>
						    </td>
						    <td id="toolbar-cancel" class="button">
						        <asp:LinkButton ID="lbtClose" runat="server" Text="" onclick="lbtClose_Click" 
                                    CssClass="toolbar" CausesValidation="False">
					                <span id="Span2" title="Close" class="icon-32-cancel" runat="server"></span>Thoát
					            </asp:LinkButton>
						    </td>
					    </tr>
				    </tbody>
			    </table>
		    </div>
			<div class="header">Thêm mới/chỉnh sửa menu</div>
			<div class="clr"></div>
		</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
	</div>
	<div id="element-box">
		<div class="t">
			<div class="t">
				<div class="t"></div>
			</div>
		</div>
		<div class="m" style="float:left; width:100%">
			<div class="admin-left">
                <table class="adminform">
                    <tr>
						<td colspan="2">
                            <div id="ErorMessage" style="color: Red;line-height: 150%;"></div>
                        </td>
					</tr>
                    <tr>
                        <td style="width: 20%;">Tên menu:</td>
                        <td><asp:TextBox id="txtMenuName" runat="server" Width="400px"></asp:TextBox></td>
                    </tr>
                    <tr>
                        <td>Chọn nhà hàng:</td>
                        <td>
                            <asp:DropDownList ID="ddlRestaurant" runat="server" Width="413px"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>Chọn bữa ăn</td>
                        <td>
                            <asp:DropDownList ID="ddlMenuType" runat="server" Width="200px"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">Chọn&nbsp;thực&nbsp;đơn:</td>
                        <td style="text-align: left" >
                            <div>
                                <input type="text" onclick="openPopup('viand')" style="width:400px;" readonly="readonly" placeholder="Click để chọn món ăn" />
                            </div>
                            <input type="hidden" id="txtViands" runat="server" value=""/>
                        </td>
                    </tr>
                    <tr>
                        <td>Giá</td>
                        <td>
                            <asp:TextBox ID="txtPrice" CssClass="validate-number" runat="server" Width="400px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>Tình trạng</td>
                        <td>
                            <asp:DropDownList ID="ddlStatus" runat="server" Width="200px"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>Người tạo</td>
                        <td>
                            <asp:DropDownList ID="ddlAdminUser" runat="server" Width="200px"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>Mô tả ngắn</td>
                        <td>
                            <asp:TextBox ID="txtSortDescription" TextMode="MultiLine" runat="server" Width="400px" Height="100px"></asp:TextBox>
                        </td>
                    </tr>
                    
                </table>  
            </div>  
            <div class="admin-right">
                <table class="adminform">
                    <tr>
                        <td colspan="2">
                            Mô tả chi tiết
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <uc1:TinyMCE runat="server" ID="txtContent" />
                        </td>
                    </tr>
                </table>
            </div>
            <div class="clr"></div>
		</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
	</div>
    
    <!-- Danh sách món ăn-->
    <link href="/css/popup.css" rel="stylesheet" />
    <script src="/js/jquery.popup.js"></script>
    <div class="popup-wrapper"></div>
    <div class="popup-main popup-viand">
        <div class="popup-content">
            <div class="popup-close icon-close" onclick="closePopup('viand')"></div>
            <% foreach (DLV.Data.Entities.ViandInfo info in ViandList) { %>
            <div class="item">
                <input type="checkbox" name="ckss" value="<%=info.ViandId %>">
                <span><%=info.ViandName %></span>
            </div>
            <%} %> 
        </div>
    </div>

    <!-- Ngôn ngữ -->
    <script type="text/javascript">
        function ShowViand() {
            document.getElementById("search").style.display = "block";
        }
        function HideViand() {
            document.getElementById("search").style.display = "none";
        }
        $(document).ready(function () {
            //đỗ dữ liệu vào các checkbox (check hay ko check)
            var arrViand = $("#<%=txtViands.ClientID %>").val();
            var arr = arrViand.split(",", 100);
            $("input[name='ckss']").each(function () {
                for (var i = 0; i < arr.length; i++) {
                    var x = $(this).val();
                    if (x == arr[i]) {
                        $(this).attr('checked', true);
                        break;
                    }
                }
            });
            //xử lý sự kiên check của checkobox
            $("[name='ckss']").change(function () {
                var str = "";
                $("input[name='ckss']:checked").each(function (i, val) {
                    if (str == "")
                        str += $(this).val();
                    else
                        str += "," + $(this).val();
                });

                $("#<%=txtViands.ClientID %>").val(str);
            });
        });
    </script>
    
    <!-- Validate -->
    <script type="text/javascript">
        $(document).ready(function () {
            $("#<%= lbtSave.ClientID %>").click(function () {
                $("#ErorMessage").html('');

                var rtnValue = validate($("#<%= txtMenuName.ClientID %>"), $("#ErorMessage"), "Vui lòng nhập tên menu<br\>")
                    && validate($("#<%= txtViands.ClientID %>"), $("#ErorMessage"), "Vui lòng chọn món ăn<br\>")
                    && validate($("#<%= txtSortDescription.ClientID %>"), $("#ErorMessage"), "Vui lòng nhập mô tả ngắn<br\>");

                return rtnValue;
            });
        });
    </script>
</asp:content>
